<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\helpers\SimpleFlagHelper;
use backend\helpers\ActionButton;
use backend\models\Event;

/* @var $this yii\web\View */
/* @var $model backend\models\Event */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'События', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

$this->params['id'] = $model->id;

?>
<div class="container event-view">

    <h1 class="main-title"><?= Html::encode($this->title) ?></h1>

    <div class="row">
        <div class="col-sm-11"><?= $this->render('/event/_menu') ?></div>
        <div class="col-sm-1"><?= ActionButton::delete($model->id, 'Вы точно хотите удалить событие?', 'deleteEvent') ?></div>
    </div>

    <?= DetailView::widget([
        'model' => $model,
        'options' => ['class' => 'table table-striped detail-view'],
        'attributes' => [
            'id',
            [
                'label' => 'Информационный канал',
                'attribute' => 'infoChanel.title',
            ],
            [
                'label' => 'Тип',
                'attribute' => 'type.title',
            ],
            'title',
            'alias',
            'description',
            'content:ntext',
            'date_start:date',
            'date_end:date',
            'time_start',
            'schedule_str',
            'pub_date',
            [
                'attribute'=>'prev_img',
                'format' => 'raw',
                'value' => function($model){
                    return Html::img(
                        'https://storage.yandexcloud.net/' . Event::BUCKET_NAME . '/' . $model->prev_img,
                        [
                            'alt'=>'',
                            'class' => 'img-thumbnail',
                            'style' => 'width:200px;'
                        ]
                    );
                },
            ],
            [
                'attribute'=>'gallery_img',
                'format' => 'raw',
                'value' => function($model){
                    $gallery = '';
                    if(!empty($model->gallery_img))
                    {
                        foreach(explode(',', $model->gallery_img) as $image)
                        {
                            $gallery .= Html::img(
                                'https://storage.yandexcloud.net/' . Event::BUCKET_NAME . '/' . $image, 
                                $options = ['class' => 'img-thumbnail', 'style' => ['width' => '200px']]
                            );
                        }   
                    }

                    return $gallery;
                },
            ],
            [
                'label' => 'Ценовая категория',
                'attribute' => 'price.title',
            ],
            'kassir_bo_id',
            'kassir_bo_type',
            [
                'attribute'=>'is_pushkart',
                'value' => function ($model) {
                    return SimpleFlagHelper::statusLabel($model->is_pushkart);
                },
                'format' => 'raw'
            ],
            [
                'attribute'=>'is_free',
                'value' => function ($model) {
                    return SimpleFlagHelper::statusLabel($model->is_free);
                },
                'format' => 'raw'
            ],
            'rars_info',
            [
                'attribute'=>'is_main_event',
                'value' => function ($model) {
                    return SimpleFlagHelper::statusLabel($model->is_main_event);
                },
                'format' => 'raw'
            ],
            [
                'attribute'=>'request',
                'value' => function ($model) {
                    return SimpleFlagHelper::statusLabel($model->request);
                },
                'format' => 'raw'
            ],
        ],
    ]) ?>

</div>
